package net.quanter.demo.junit5.dubbo.provider.service.impl;

import net.quanter.demo.junit5.client.dto.UserDTO;
import net.quanter.demo.junit5.client.service.UserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * 测试dubbo方法,该方法为dubbo的服务端
 * 2020-06-08
 * @author 王老实
 *
 */
@Service("UserServiceImpl")
public class UserServiceImpl implements UserService {
    static Map<Integer,UserDTO> userMap = new HashMap();
    static {
        List<UserDTO> userDTOList = new ArrayList();
        userDTOList.add(new UserDTO(1,"杨超越",18));
        userDTOList.add(new UserDTO(2,"孟美岐",20));
        userDTOList.add(new UserDTO(3,"肖战",23));
        userMap = userDTOList.stream().collect(java.util.stream.Collectors.toMap(UserDTO::getId, x -> x));
    }

    @Override
    public UserDTO get(Integer id) {
        return userMap.get(id);
    }
}
